package com.huawei.appmarket.service.usercenter.award.activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appmarket.service.usercenter.award.protocol.AwardProtocol;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.lang.ref.WeakReference;
import o.AccountBussinessListener;
import o.ccp;
import o.der.f;
import o.Logger;
import o.dof;
import o.doo;
import o.emz;
import o.eod;
import o.eoj;
import o.epq$c;
import o.eqn;
import o.eqq;
import o.evk;

public class MyAwardActivity extends BaseActivity<AwardProtocol> {
    private static String ͺ = "award_login";
    private String ˏॱ = "";

    static class a implements AccountBussinessListener {
        b ˏ;

        a(b bVar) {
            this.ˏ = bVar;
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            if (o_ccp != null && o_ccp.ˎ != 102) {
                this.ˏ.sendEmptyMessage(10002);
            }
        }
    }

    static class b extends Handler {
        private WeakReference<MyAwardActivity> ˎ;

        public b(MyAwardActivity myAwardActivity) {
            this.ˎ = new WeakReference(myAwardActivity);
        }

        public void handleMessage(Message message) {
            MyAwardActivity myAwardActivity = (MyAwardActivity) this.ˎ.get();
            if (myAwardActivity != null) {
                if (message.what == 10001) {
                    myAwardActivity.ᐝ();
                } else if (message.what == 10002) {
                    myAwardActivity.finish();
                }
            }
        }
    }

    static class d implements eqn {
        b ˋ;

        d(b bVar) {
            this.ˋ = bVar;
        }

        public void onResult(int i) {
            switch (i) {
                case 201:
                    return;
                case 202:
                    this.ˋ.sendEmptyMessage(10001);
                    return;
                default:
                    this.ˋ.sendEmptyMessage(10002);
                    return;
            }
        }
    }

    public void onCreate(Bundle bundle) {
        requestWindowFeature(1);
        super.onCreate(bundle);
        getWindow().setBackgroundDrawableResource(o.der.a.ʼ);
        if (UserSession.getInstance().isLoginSuccessful()) {
            ᐝ();
            return;
        }
        Logger.ˎ("MyAwardActivity", "not login");
        if (doo.ˊ(this)) {
            b bVar = new b(this);
            eqq.ˋ().ˎ(ͺ, new d(bVar));
            eoj.ˋ().ˎ(ͺ, new a(bVar));
            eod.ॱ(this);
            return;
        }
        Logger.ˎ("MyAwardActivity", "no network");
        evk.ˏ(this, f.ʻʽ, 0).ˋ();
        finish();
    }

    private void ᐝ() {
        try {
            String str;
            this.ˏॱ = epq$c.ˊ() + "awardCategory=";
            AwardProtocol awardProtocol = (AwardProtocol) ʾ();
            String str2 = "2";
            if (awardProtocol == null || awardProtocol.ˋ() == null) {
                str = str2;
            } else {
                str = ˋ(awardProtocol.ˋ().ˎ());
            }
            emz.ॱ(this, "internal_webview", this.ˏॱ + str);
            finish();
        } catch (Exception e) {
            Logger.e("MyAwardActivity", "sendEventToServerException");
        }
    }

    private String ˋ(String str) {
        return (dof.ॱ(str) || !("2".equals(str) || "3".equals(str) || HwAccountConstants.TYPE_SINA.equals(str))) ? "2" : str;
    }

    public void onDestroy() {
        eoj.ˋ().ˊ(ͺ);
        eqq.ˋ().ˊ(ͺ);
        super.onDestroy();
    }
}
